﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link type="text/css" rel="stylesheet" media="all" href="../../styles/global.css"/>
    <link type="text/css" rel="stylesheet" media="all" href="../../styles/global_color.css"/>
    <script language="javascript" type="text/javascript">
        //显示角色详细信息
        function showDetail(flag, a) {
            var detailDiv = a.parentNode.getElementsByTagName("div")[0];
            if (flag) {
                detailDiv.style.display = "block";
            }
            else
                detailDiv.style.display = "none";
        }
        //删除
        function deleteAccount(sid) {
            var r = window.confirm("确定要删除此业务账号吗？删除后将不能恢复。");
            if (r) {
                $.ajax({
                    url: "/delservice",
                    type: "post",
                    data: {
                        serviceId: sid
                    },
                    success: function () {
                        document.getElementById("operate_result_info").style.display = "block";
                        window.location.href = "/servicelist";
                    }
                });
            }

        }
        //开通或暂停
        function setState() {
            var r = window.confirm("确定要开通此业务账号吗？");
            document.getElementById("operate_result_info").style.display = "block";
        }
    </script>
</head>
<body>
<!--Logo区域开始-->
<div id="header">
    <img src="../../images/logo.png" alt="logo" class="left"/>
    <a href="/logout">[退出]</a>
</div>
<!--Logo区域结束-->
<!--导航区域开始-->
<div id="navi">
    <ul id="menu">
        <li><a href="/index" class="index_on"></a></li>
        <li><a href="/rolelist" class="role_off"></a></li>
        <li><a href="/adminList" class="admin_off"></a></li>
        <li><a href="/feelist" class="fee_off"></a></li>
        <li><a href="/accountlist" class="account_off"></a></li>
        <li><a href="/servicelist" class="service_off"></a></li>
        <li><a href="/billList" class="bill_off"></a></li>
        <li><a href="/reportList" class="report_off"></a></li>
        <li><a href="/userInfo" class="information_off"></a></li>
        <li><a href="/userModiPwd" class="password_off"></a></li>
    </ul>
</div>
<!--导航区域结束-->
<!--主要区域开始-->
<div id="main">
    <form action="" method="">
        <!--查询-->
        <div class="search_add">
            <div>OS 账号：<input type="text" value="" class="width100 text_search"/></div>
            <div>服务器 IP：<input type="text" value="" class="width100 text_search"/></div>
            <div>身份证：<input type="text" value="" class="text_search"/></div>
            <div>状态：
                <select class="select_search">
                    <option>全部</option>
                    <option>开通</option>
                    <option>暂停</option>
                    <option>删除</option>
                </select>
            </div>
            <div><input type="button" value="搜索" class="btn_search"/></div>
            <input type="button" value="增加" class="btn_add" onclick="location.href='/serviceAdd';"/>
        </div>
        <!--删除的操作提示-->
        <div id="operate_result_info" class="operate_success">
            <img src="../images/close.png" onclick="this.parentNode.style.display='none';"/>
            删除成功！
        </div>
        <!--数据区域：用表格展示数据-->
        <div id="data">
            <table id="datalist">
            </table>
            <p>业务说明：<br/>
                1、创建即开通，记载创建时间；<br/>
                2、暂停后，记载暂停时间；<br/>
                3、重新开通后，删除暂停时间；<br/>
                4、删除后，记载删除时间，标示为删除，不能再开通、修改、删除；<br/>
                5、业务账号不设计修改密码功能，由用户自服务功能实现；<br/>
                6、暂停和删除状态的账务账号下属的业务账号不能被开通。</p>
        </div>
        <!--分页-->
        <div id="pages">
        </div>
    </form>
</div>
<!--主要区域结束-->
<div id="footer">
    <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
    <p>版权所有(C)云科技有限公司 </p>
</div>
<script src="../../js/jquery-3.2.1.js"></script>
<script>
    //修改
    function updateService(serviceId) {
        window.location.href = '/serviceupdate?serviceId=' + serviceId + '';
    }
    var ip = 1;
    $.ajax({
        url: "/servicePage",
        type: "post",
        data: {
            pagenum: ip
        },
        success: function (data) {
            $("#datalist").append("<tr><th class='width50'>业务ID</th><th class='width70'>账务账号ID</th><th class='width150'>身份证</th><th class='width70'>姓名</th><th>OS 账号</th><th class='width50'>状态</th><th class='width100'>服务器 IP</th><th class='width100'>资费</th><th class='width200'></th></tr>");
            for (var i in data.list) {
                var service = data.list[i];
                var sid = service.serviceId;
                var aid = service.accountId;
                var os = service.osUsername;
                var IP = service.unixHost;
                var status = service.status;
                var ss = service.status;
                for (var j in service.aList) {
                    var account = service.aList[j];
                    var idcard = account.idcardNo;
                    var aname = account.realName;
                }
                for (var k in service.cList) {
                    var cost = service.cList[k];
                    var cname = cost.name;
                    var desc = cost.descr;
                }
                var s = null;
                if (status == 0) {
                    status = "开通";
                    s = "暂停";
                    $("#datalist").append("<tr><td><a href='javascript:void(0)' onclick='showdetail(" + sid + ");' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' class='btn_pause' onclick=\"setState('" + sid + "," + ss + "')\"/><input type='button' value='修改' class='btn_modify' onclick='updateService(" + sid + ")'/><input type='button' value='删除' class='btn_delete' onclick='deleteService(" + sid + ");'/></td></tr>")
                }
                if (status == 1) {
                    status = "暂停";
                    s = "启用";
                    $("#datalist").append("<tr><td><a href='javascript:void(0)' onclick='showdetail(" + sid + ");' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' class='btn_start' onclick=\"setState('" + sid + "," + ss + "')\"/><input type='button' value='修改' class='btn_modify' onclick='updateService(" + sid + ")'/><input type='button' value='删除' class='btn_delete' onclick='deleteService(" + sid + ");'/></td></tr>")
                }
                if (status == 2) {
                    status = "删除";
                    s = " ";
                    $("#datalist").append("<tr><td><a href='javascript:void(0)' onclick='showdetail(" + sid + ");' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' onclick=\"setState('" + sid + "," + ss + "')\"/></td></tr>")
                }
            }
            //            当前页码
            var pageNum = data.pageNum;
//            每页的数量
            var pageSize = data.pageSize;
//            当前页的数量
            var size = data.size;
//            数据总数
            var total = data.total;
//            一共多少页
            var pages = data.pages;
//            首页是多少
            var firstPage = data.firstPage;
//            上一页是多少
            var prePage = data.prePage;
//            下一页是多少
            var nextPage = data.nextPage;
//            最后一页是多少
            var lastPage = data.lastPage;
//            是否是首页
            var isFirstPage = data.isFirstPage;
//            是否是尾页
            var isLastPage = data.isLastPage;
            if (isFirstPage) {
                prePage = prePage + 1;
            }
            if (isLastPage) {
                nextPage = lastPage;
            }
            $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + prePage + ")'>" + "<<<" + "</a>"));
            for (i = 1; i <= lastPage; i++) {
                $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + i + ")'>" + i + "</a>"))
            }
            $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + nextPage + ")'>" + ">>>" + "</a>"));
            var urlstatus = false;
            if (!urlstatus) {
                $("#pages a").eq(1).addClass('current_page');
            }
        }
    });
    function page(i) {
        ip = i;
        $.ajax({
            url: "/servicePage",
            type: "post",
            data: {
                pagenum: ip
            },
            success: function (data) {
                $("#datalist").html("");
                $("#datalist").append("<tr><th class='width50'>业务ID</th><th class='width70'>账务账号ID</th><th class='width150'>身份证</th><th class='width70'>姓名</th><th>OS 账号</th><th class='width50'>状态</th><th class='width100'>服务器 IP</th><th class='width100'>资费</th><th class='width200'></th></tr>");
                for (var i in data.list) {
                    var service = data.list[i];
                    var sid = service.serviceId;
                    var aid = service.accountId;
                    var os = service.osUsername;
                    var IP = service.unixHost;
                    var status = service.status;
                    var ss = service.status;
                    for (var j in service.aList) {
                        var account = service.aList[j];
                        var idcard = account.idcardNo;
                        var aname = account.realName;
                    }
                    for (var k in service.cList) {
                        var cost = service.cList[k];
                        var cname = cost.name;
                        var desc = cost.descr;
                    }
                    var s = null;
                    if (status == 0) {
                        status = "开通";
                        s = "暂停";
                        $("#datalist").append("<tr><td><a href='javascript:void(0)' onclick='showdetail(" + sid + ");' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' class='btn_pause' onclick=\"setState('" + sid + "," + ss + "')\"/><input type='button' value='修改' class='btn_modify' onclick='updateService(" + sid + ")'/><input type='button' value='删除' class='btn_delete' onclick='deleteService(" + sid + ");'/></td></tr>")
                    }
                    if (status == 1) {
                        status = "暂停";
                        s = "启用";
                        $("#datalist").append("<tr><td><a href='javascript:void(0)' onclick='showdetail(" + sid + ");' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' class='btn_start' onclick=\"setState('" + sid + "," + ss + "')\"/><input type='button' value='修改' class='btn_modify' onclick='updateService(" + sid + ")'/><input type='button' value='删除' class='btn_delete' onclick='deleteService(" + sid + ");'/></td></tr>")
                    }
                    if (status == 2) {
                        status = "删除";
                        s = " ";
                        $("#datalist").append("<tr><td><a href='service_detail.html' title='查看明细'>" + sid + "</a></td><td>" + aid + "</td><td>" + idcard + "</td><td>" + aname + "</td><td>" + os + "</td><td>" + status + "</td><td>" + IP + "</td><td><a class='summary' onmouseover='showDetail(true,this);' onmouseout='showDetail(false,this);'>" + cname + "</a> <div class='detail_info'>" + desc + "</div></td><td class='td_modi'> <input type='button' value='" + s + "' onclick='setState();'/></td></tr>")
                    }
                }
                //            当前页码
                var pageNum = data.pageNum;
//            每页的数量
                var pageSize = data.pageSize;
//            当前页的数量
                var size = data.size;
//            数据总数
                var total = data.total;
//            一共多少页
                var pages = data.pages;
//            首页是多少
                var firstPage = data.firstPage;
//            上一页是多少
                var prePage = data.prePage;
//            下一页是多少
                var nextPage = data.nextPage;
//            最后一页是多少
                var lastPage = data.lastPage;
//            是否是首页
                var isFirstPage = data.isFirstPage;
//            是否是尾页
                var isLastPage = data.isLastPage;
                if (isFirstPage) {
                    prePage = prePage + 1;
                }
                if (isLastPage) {
                    nextPage = lastPage;
                }
                $("#pages").html("");
                $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + prePage + ")'>" + "<<<" + "</a>"));
                for (i = 1; i <= lastPage; i++) {
                    $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + i + ")'>" + i + "</a>"))
                }
                $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + nextPage + ")'>" + ">>>" + "</a>"));
                $("#pages a").siblings('a').removeClass('selected');
                $("#pages a").eq(pageNum).addClass('current_page');
            }
        });
    }
    //显示角色详细信息
    function showDetail(flag, a) {
        var detailDiv = a.parentNode.getElementsByTagName("div")[0];
        if (flag) {
            detailDiv.style.display = "block";
        }
        else
            detailDiv.style.display = "none";
    }
    function showdetail(serviceId) {
        window.location.href = '/servicedetail?serviceId=' + serviceId + '';
    }
    //删除
    function deleteService(serviceId) {
        var r = window.confirm("确定要删除此业务账号吗？删除后将不能恢复。");
        if (r) {
            $.ajax({
                url: "/delservice",
                type: "post",
                data: {
                    serviceId: serviceId
                },
                success: function () {
                    window.location.href = "/servicelist";
                    document.getElementById("operate_result_info").style.display = "block";
                }
            });
        }

    }
    //开通或暂停
    function setState(result) {
        var indexof = result.indexOf(",");
        var status = result.substr(-1, 1);
        var serviceId = result.substr(0, indexof);
        if (status == 0) {
            if (window.confirm("确定要暂停此账务账号吗？")) {
                $.ajax({
                    url: "/updateStatusByServiceId",
                    type: "post",
                    data: {
                        status: 1,
                        serviceId: serviceId
                    },
                    success: function () {
                        window.location.href = "/servicelist";
                        document.getElementById("operate_result_info").style.display = "block";
                    }
                });
            }
        }
        if (status == 1) {
            if (window.confirm("确定要开通此账务账号吗？")) {
                $.ajax({
                    url: "/updateStatusByServiceId",
                    type: "post",
                    data: {
                        status: 0,
                        serviceId: serviceId
                    },
                    success: function () {
                        window.location.href = "/servicelist";
                        document.getElementById("operate_result_info").style.display = "block";
                    }
                });
            }
        }
    }
    function updateservice(servideId) {
        window.location.href = '/serviceupdate?sid=' + servideId + '';
    }
</script>
</body>
</html>
